package top.shiyiri.servlet2;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Aunean
 * @date 2022/1/28 16:21
 */
public class Response1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("曾到此一游 Response1");

        //方式一：重定向
//        //设置响应状态码，表示重定向
//        resp.setStatus(302);
//        //设置响应头，说明新的地址在哪里
//        resp.setHeader("Location", "http://localhost:8080/day06_servlet_war_exploded/response2");

        //方式二：重定向
        resp.sendRedirect("http://localhost:8080");
    }
}
